		TITLE	READSEQ - Copyright (c) SLR Systems 1994

		INCLUDE MACROS

		PUBLIC	READ_EAXECX_EDXEBX_RANDOM


		.DATA

		EXTERNDEF	OPTI_STOSD_SIZE:DWORD


		.CODE	CVPACK_TEXT

		EXTERNDEF	GET_NEW_LOG_BLK:PROC,ERR_ABORT:PROC

		EXTERNDEF	ILLEGAL_READ_ADDRESS_ERR:ABS


READ_EAXECX_EDXEBX_RANDOM	PROC
		;
		;EAX IS DESTINATION STRING
		;ECX IS BYTE COUNT TO READ
		;EDX IS DATA-TYPE STRUCTURE TO USE
		;EBX IS SOURCE ADDRESS
		;
		ASSUME	EDX:PTR SEQ_STRUCT

		PUSH	EDI
		MOV	EDI,EBX

		SHR	EDI,16-PAGE_SHIFT
		AND	EBX,PAGE_SIZE-1

		PUSH	ESI
		MOV	ESI,EAX

		MOV	EAX,PAGE_SIZE
		LEA	EDX,[EDX+EDI*4]._SEQ_TABLE
		ASSUME	EDX:NOTHING

		SUB	EAX,EBX

		CMP	EAX,ECX
		MOV	EDI,[EDX]

		JC	RDBS_TWO			;NOPE, NEED TWO
RDBS_TWO_1:
		TEST	EDI,EDI
		JZ	L8$

		ADD	EDI,EBX
		MOV	EBX,ECX

		SHR	ECX,2
		JZ	L3$
L1$:
		MOV	EAX,[EDI]
		ADD	EDI,4

		MOV	[ESI],EAX
		ADD	ESI,4

		DEC	ECX
		JNZ	L1$
L3$:
		AND	EBX,3
		JNZ	L7$

		POPM	ESI,EDI

		RET

L7$:
		MOV	AL,[EDI]
		INC	EDI

		MOV	[ESI],AL
		INC	ESI

		DEC	EBX
		JNZ	L7$

		POPM	ESI,EDI

		RET

RDBS_TWO:
		;OOPS, CROSSES A 16K BLOCK BOUNDARY...	DO TWO MOVES

		SUB	ECX,EAX
		CALL	RDBS_TWO_PROC

		XOR	EBX,EBX
		JMP	RDBS_TWO_1

L8$::
		MOV	AL,ILLEGAL_READ_ADDRESS_ERR
		CALL	ERR_ABORT

READ_EAXECX_EDXEBX_RANDOM	ENDP


RDBS_TWO_PROC	PROC	NEAR
		;
		;
		;
		TEST	EDI,EDI
		PUSH	ECX

		MOV	ECX,EAX
		JZ	L8$

		ADD	EDI,EBX
		ADD	EDX,4

		MOV	EBX,ECX

		SHR	ECX,2
		JZ	L5$
L4$:
		MOV	EAX,[EDI]
		ADD	EDI,4

		MOV	[ESI],EAX
		ADD	ESI,4

		DEC	ECX
		JNZ	L4$
L5$:
		AND	EBX,3
		JNZ	L7$
L6$:
		POP	ECX
		MOV	EDI,[EDX]

		RET

L7$:
		MOV	AL,[EDI]
		INC	EDI

		MOV	[ESI],AL
		INC	ESI

		DEC	EBX
		JNZ	L7$

		JMP	L6$

RDBS_TWO_PROC	ENDP


		END

